#pragma once

#include <QObject>
#include <QHash>
#include <QList>
#include <memory>
#include "charge_point.h"
#include "kernel/interfaces/ILogger.h"

namespace application {
namespace charge {

/**
 * @brief 充电点管理器
 * @details 管理单个楼层的所有充电点
 */
class ChargeManager : public QObject {
    Q_OBJECT

public:
    explicit ChargeManager(int floor, std::shared_ptr<kernel::ILogger> logger = nullptr, QObject* parent = nullptr);
    ~ChargeManager() = default;

    // 充电点管理
    void addChargePoint(std::shared_ptr<ChargePoint> chargePoint);
    void removeChargePoint(const QString& pointId);
    std::shared_ptr<ChargePoint> getChargePoint(const QString& pointId) const;

    // 查询
    bool hasChargePoint(const QString& pointId) const;
    QList<QString> getAllChargePointIds() const;
    int getFloor() const { return m_floor; }

    // 查找可用充电点
    std::shared_ptr<ChargePoint> findAvailableChargePoint(int agvNumber = -1) const;
    QList<std::shared_ptr<ChargePoint>> getAvailableChargePoints(int agvNumber = -1) const;

    // 初始化
    void initializeChargePoints();

signals:
    void chargePointAdded(const QString& pointId);
    void chargePointRemoved(const QString& pointId);
    void chargePointAvailabilityChanged(const QString& pointId, bool available);

private:
    int m_floor;
    QHash<QString, std::shared_ptr<ChargePoint>> m_chargePoints;
    std::shared_ptr<kernel::ILogger> m_logger;
};

} // namespace charge
} // namespace application
